<include file="Public:header"/>
<script type="text/javascript" src="__PUBLIC__/js/layer/layer.js"></script>
<!--表情-->
<!-- <script type="text/javascript" src="__PUBLIC__/script/emotions.js"></script> -->
<div class="container app">
	<include file="Public/sidebar" /> 
	<div id="mainCon" class="mainCon">

		<style>
			.systemcallback{
				margin-top:10%;
				text-align:center;
			}
			.systemcallback li{
				display:inline-block;
				margin:0 30px;
			}
			.systemcallback li a{
				height:50px;
				padding:20px;
				font-size:24px;
				color:#fff;
			}
			.systemcallback a[attr='text']{
				background:rgb(165,197,98);
			}
			.systemcallback a[attr='news']{
				background:rgb(145,223,243);
			}
			.systemcallback a[attr='setup']{
				background:rgb(253,197,84);
			}
			.selecttitle{
				font-size:48px;
				width:100%;
				text-align:center;
				margin-top:5%;
			}
			.checked{
				position:absolute;
				font-size:48px;
				display:none;
				color:rgb(163, 0, 255);
			}
		</style>
			<div class='content cbd'>
				<div class="sub-item">
						<span class='checked'><i class='glyphicon glyphicon-ok'></i></span>
						<div class='selecttitle'>选择一种适合您的方式</div>
						<div class="systemcallback">
							<ul>
								<li ><a href="javascript:" attr='text'>基本文字</a></li>
								<!--<li ><a href="javascript:" attr='news'>高级图文设置</a></li>-->
								<!-- <li ><a  href="javascript:" attr='setup'>系统应用</a></li> -->
							</ul>
						</div>
						
						<form action="" method="post" enctype="multipart/form-data">
							<input type='hidden' name='type' value="<empty name="Think.get.op">subscription<else/><{$op}></empty>"/>
							<input type='hidden' class='postmodule' name='postmodule' value='text'/>
							<input type='hidden' name='module' value="news"/>
							<input type="hidden" name="id" value="<{$wechatid}>">
							<div class="text postdiv" style='display:none;margin-left:95px'>
								<eq name="op" value="welcome">
								<textarea name="welcome" id="welcome" cols="25" rows="10" style='width:500px;height:250px;' ><{$text}></textarea>
								<{:A('Admin/Editor')->buildEditor('welcome',"'link','source'");}>
								<else/>
								<textarea name="default" id="default" cols="25" rows="10" style='width:500px;height:250px;' ><{$text}></textarea>
								<{:A('Admin/Editor')->buildEditor('default',"'link','source'");}>
								</eq>
							</div>
							<div class='news postdiv' style='display:none'>
									<eq name="wechatrow['rule']['module']"  value="news">
										   <?php $id=$wechatrow['news']['id'];?>
										   <?php $newtitle='news-title[news-wrap-item-'.$id.']['.$id.']';?>
										   <?php $keyword='keyword-name['.$id.']';?>
										   <?php $newspic='news-picture[news-wrap-item-'.$id.']['.$id.']';?>
										   <?php $description='news-description[news-wrap-item-'.$id.']['.$id.']';?>
										   <?php $url='news-url[news-wrap-item-'.$id.']['.$id.']';?>
									<else/>
											<?php $id=0;?>
											<?php $newtitle='news-title-new[news-wrap-item-'.$id.']['.$id.']';?>
											<?php $keyword='keyword-name-new['.$id.']';?>
											<?php $newspic='news-picture-new[news-wrap-item-'.$id.']['.$id.']';?>
											<?php $description='news-description-new[news-wrap-item-'.$id.']['.$id.']';?>
											<?php $url='news-url-new[news-wrap-item-'.$id.']['.$id.']';?>
									</eq>
									<table >
										<tr>
											<th>标题</th>
											<td>
												<input type='text' name="title" class='span3' value="<{$wechatrow['news']['title']}>"/>
												<input type='hidden' id='newtitle' name="<{$newtitle}>" class='span3' value="<{$wechatrow['news']['title']}>"/>
												<input type='hidden' name="<{$keyword}>" class='span3' value="<notempty name="wechatrow['keyword'][0]['content']"><{$wechatrow['keyword'][0]['content']}><else/><{$op}></notempty>"/>
											</td>
										</tr>
										<tr>
											<th>活动图片</th>
											<td>
												<div class="upload-file-box">
													<span class="pull-right">大图片建议尺寸：700像素 * 300像素</span>
													<input type="button" class='btn btn-default uploadimgbtn'  onclick="showgallery('<{$newspic}>')" value="选择图片" />
													<div id="upload-file-view" class="upload-view">
														<notempty name="wechatrow['news']['thumb']">
															<img src="<{$Think.config.SELF_IMAGE_HOST}><{$wechatrow['news']['thumb']}>"/>
															<input type="hidden" name="<{$newspic}>" value="<{$wechatrow['news']['thumb']}>"/>
															<a href="javascript:void(0)" onclick="removeOthersImage(this)">
																<i class="icon-remove"></i>
															</a>
														<else/>
															  <img src="__PUBLIC__/image/blue/common_33.jpg" >
														</notempty>
													</div>
												</div>
											</td>
										</tr>
										<tr>
											<th>描述</th>
											<td>
												<input type='text' name="<{$description}>" value="<{$wechatrow['news']['description']}>" class='span5'/>
											</td>
										</tr>
										<tr>
											<th>原文链接</th>
											<td>
												<input type='text' id='url' class='span5' name='<{$url}>' value="<notempty name="wechatrow['news']['url']"><{$wechatrow['news']['url']}><else/>http://</notempty>"/>
												<button type='button' onclick="SelectContractInfo(this);return false;" class="btn btn-default" id="btn0" style="margin-left:10px">快捷选择</button>
											</td>
										</tr>
								</table>
							</div>
							 <div class='setup postdiv' style='display:none'>
								<notempty name="modules[$wechatrow['rule']['module']]['title']">
								<table class="tb table table-bordered " style='width:500px;'>
									<tr class="control-group">
										<td class="rule-content" style="font-size:17px; height:21px;line-height:21px;">
											<h4>
												<span style='float:left;padding-left:20pxfont-weight:bold;'><{$wechatrow['rule']['name']}> &nbsp;&nbsp;（<{$modules[$wechatrow['rule']['module']]['title']}>）</span>
											</h4>
										</td>
									</tr>
									<tr class="control-group">
										<td class="rule-kw">
											<div>
												<volist name="wechatrow['keyword']" id="kw">
												<span class="label label-success" style='float:left;margin-left:10px;font-size:15px;padding: 4px 10px;'><{$kw['content']}></span>
												</volist>
											</div>
											<div style='clear:both'></div>
										</td>
									</tr>
								</table>
								</notempty>
								<a class="btn btn-default" onclick='showuserinfo()' id="guide_reply_content">选中应用</a>
							 </div>
							<div style='clear:both'></div>

							<div class='form-actions text-center footerbutton' style='margin-top:20px;display:none;'>
									<button type="submit" class="btn btn-danger span3"   name="submit" value="保存">保存</button>
							</div>
							<div style='clear:both'></div>
						</form>
				</div>
			</div>

		</div>
</div>

<script>


$('.text').show();
$(".systemcallback").hide();
$(".selecttitle").hide();
$(".footerbutton").show();
<empty  name="text">
	<if condition = "$wechatrow['rule']['module'] !='news' and $wechatrow['rule']['module'] " >
	    //活动
		$(".checked").css({'top':$("a[attr='setup']").offset().top-35,'left':$("a[attr='setup']").offset().left+$("a[attr='setup']").width()}).show();
	</if>
<else/>
	//基本文字
	$(".checked").css({'top':$("a[attr='text']").offset().top-35,'left':$("a[attr='text']").offset().left+$("a[attr='text']").width()}).show();
</empty>

$("input[name='title']").blur(function(){
    $("#newtitle").val($(this).val());
});
$("form").submit(function(){
        var postmoduel=$(".postmodule").val();
        var url=''
        if(postmoduel =='text'){
            url="<{:U('Rule/System')}>";
        }else if(postmoduel =='news'){
            url="<{:U('Rule/Post')}>";
            if($("#url").val() == '' || $("#url").val() == undefined ){
                $("#url").focus();
               //message('自定义图文原文链接不能为空',null,0);
                return false;
            }
        }
		$.post(url,$(this).serializeArray(),function(data){
		    if(data.status){
		        $.post("<{:U('Rule/Setdefaultwelcome',array('type'=>$op))}>",{'id':data.info.returnid},function(e){
		
				});
		    }
			
			if(data.status){
				layer.alert('保存成功',{icon: 1});
			}
			//message(data.info.info,"<{:U('Rule/system',array('op'=>$op))}>",data.status);
		});
		return false;
});

//切换类型
$(".systemcallback li").click(function(){
    var inattr=$(this).find('a').attr('attr');
    if(inattr == '' || inattr == undefined){
        return;
    }
    $(".postdiv").hide();
    $("."+inattr).show();
    $(".footerbutton").show();
	$(".postmodule").val(inattr);
	$(".selecttitle").hide();
	$(".checked").hide();
	$(".systemcallback").hide();

});

</script>
